/**
 * 定义应用路由
 */
import React from 'react';
import { Router, hashHistory, } from 'react-router';
import auth from './auth';
// 路由配置规则参考： https://github.com/ReactTraining/react-router/blob/v3/docs/guides/RouteConfiguration.md#configuration-with-plain-routes
// 一下部分是由 ICE 相关工具自动生成的路由，请勿随意改变，否则可能会出现一些异常情况
// <!-- auto generated routes start -->
import { Homeindex } from './pages/Homeindex';
import BlankLayout from './layouts/BlankLayout';
import HeaderFooterLayout from './layouts/HeaderFooterLayout';
import HeaderAsideFooterResponsiveLayout from './layouts/HeaderAsideFooterResponsiveLayout';
import Home from './pages/Home';
import { Login, Admin } from './pages/Login';
import ForgetPassword from './pages/ForgetPassword';
import { NotFound, BasicException, NotPermission, EmptyContent } from './pages/ErrorPage';
import { Register, RegisterComplete, RegisterFail } from './pages/Register';
import { Channel, AddChannel, EditChannel } from './pages/Channel';
import { Company, AddCompany, EditCompany, SupplementCompany } from './pages/Company';
import { User, AddUser, EditUser } from './pages/User';
import { Publish, PublishList } from './pages/Publish';
import { Homepage } from './pages/Homepage';
const autoGeneratedRoutes = [{
  path: 'Homeindex',
  childRoutes: [],
  component: BlankLayout,
  indexRoute: {
    component: Homeindex
  }
}, {
  path: 'Homepage',
  childRoutes: [],
  component: HeaderAsideFooterResponsiveLayout,
  indexRoute: {
    component: Homepage
  }
}, {
  path: '/company',
  childRoutes: [{
    path: 'list',
    component: Company,
    onEnter: auth
  }, {
    path: 'add',
    component: AddCompany,
    onEnter: auth
  }, {
    path: 'edit/:id',
    component: EditCompany,
    onEnter: auth
  }, {
    path: 'supplement',
    component: SupplementCompany,
    onEnter: auth
  }],
  component: HeaderAsideFooterResponsiveLayout,
  onEnter: auth
}, {
  path: '/channel',
  childRoutes: [{
    path: 'list',
    component: Channel,
    onEnter: auth
  }, {
    path: 'add',
    component: AddChannel,
    onEnter: auth
  }, {
    path: 'edit/:id',
    component: EditChannel,
    onEnter: auth
  }],
  component: HeaderAsideFooterResponsiveLayout,
  onEnter: auth
}, {
  path: '/user',
  childRoutes: [{
    path: 'list',
    component: User,
    onEnter: auth
  }, {
    path: 'add',
    component: AddUser,
    onEnter: auth
  }, {
    path: 'edit/:username',
    component: EditUser,
    onEnter: auth
  }],
  component: HeaderAsideFooterResponsiveLayout,
  onEnter: auth
}, {
  path: '/error',
  childRoutes: [{
    path: '401',
    component: NotPermission
  }, {
    path: '404',
    component: NotFound
  }, {
    path: '500',
    component: BasicException
  }, {
    path: 'empty',
    component: EmptyContent
  }],
  component: BlankLayout,
  indexRoute: {
    component: NotFound
  }
}, {
  path: '/forgetPassword',
  childRoutes: [],
  component: HeaderFooterLayout,
  indexRoute: {
    component: ForgetPassword
  },
  onEnter: auth
}, {
  path: '/register',
  childRoutes: [{
    path: 'complete',
    component: RegisterComplete
  }, {
    path: 'fail',
    component: RegisterFail
  }],
  component: HeaderFooterLayout,
  indexRoute: {
    component: Register
  },
  onEnter: auth
}, {
  path: '/login',
  childRoutes: [],
  component: BlankLayout,
  indexRoute: {
    component: Login
  },
  onEnter: auth
}, {
  path: '/admin',
  childRoutes: [],
  component: BlankLayout,
  indexRoute: {
    component: Admin
  },
  onEnter: auth
}, {
  path: '/loginout',
  childRoutes: [],
  component: BlankLayout,
  indexRoute: {
    component: Login
  },
  onEnter: auth
}, {
  path: 'publish',
  childRoutes: [{
    path: 'list',
    component: PublishList,
    onEnter: auth
  }, {
    path: 'add',
    component: Publish,
    onEnter: auth
  }],
  component: HeaderAsideFooterResponsiveLayout,
  indexRoute: {
    component: PublishList,
    onEnter: auth
  }
}, {
  path: '/',
  childRoutes: [],
  component: BlankLayout,
  indexRoute: {
    component: Homeindex
  },
  onEnter: auth
}, {
  path: '/',
  childRoutes: [{
    path: '*',
    childRoutes: [],
    component: NotFound
  }],
  component: HeaderFooterLayout
}];
// <!-- auto generated routes end -->

// 自定义路由，如果 path 相同则会覆盖自动生成部分的路由配置
const customRoutes = [];

export default (
  <Router history={hashHistory} routes={[...autoGeneratedRoutes, ...customRoutes]} />
);
